home *** CD-ROM | disk | FTP | other *** search
/ Business Heaven / Business Heaven.iso / members / rand / rand2.hlp < prev    next >
Text File  |  1993-09-05  |  5KB  |  125 lines

  1. PROGRAM:Raffle Gen                        VER:5.5
  2.   DESCR:Pulls 4 digit #s out of Hat (not same # twice)
  3.  AUTHOR:FAST ENTRY PROGRAMMING
  4.         Walter Killeen
  5.         210 S. Lopez St.
  6.         New Orleans, LA 70119
  7.         (504)827-5989
  8.         Compuserve:71511,35
  9.         FidoNet:1:396/17.22
  10.  
  11. Requires:DOS3.1  Monitor:CGA or Mono
  12.    Drive:Hard or ram (for performance)
  13. Registration $25
  14.  
  15. Rand2.exe is a random number Generator of excellent flexibility.
  16. It was designed to produce a WINNING number such as is used in a
  17. raffle or door prize situation. Once it picks a winner, and
  18. displays it with suitable fanfare on the screen, that number,
  19. along with the time and date it was picked will be added to a
  20. list of numbers no longer considered valid for choosing. (Sort of
  21. like pulling tickets from a hat)
  22.  
  23. In addition if the file GoodNums.lst exists, only numbers that
  24. exist in that file are considered valid. Further, the order in
  25. which a number is entered in the file HAS NO BEARING on how
  26. likely it will be picked.
  27.  
  28. ┌───────────────────┐
  29. │HOW RAND2.EXE WORKS│
  30. └───────────────────┘
  31. To start Rand type: RAND2 {Which Random to Pick}
  32.  
  33. 1. If the File: GoodNums.lst exists and contains, on its first
  34.    line the words:ALL VALID NUMBERS, RAND2 will count the number
  35.    of lines that it contains and save it (in NumOfLines for those
  36.    of you tracking the source code)
  37.  
  38. 2. Based on the microsecond that the random number generator is
  39.    started an x digit random number is generated (one digit at a
  40.    time). X is based on the number of digits in the NumOfLines
  41.    variable above. The number is then checked to be sure that it
  42.    is less than or equal to NumOfLines. If so, it is copied to
  43.    LineWin (integer) and ThisNumStr (a text string) otherwise
  44.    another x digit random number is generated.
  45.  
  46. 3. If the File: GoodNums.lst exists, the file will be scanned
  47.    sequentially for the line number stored in the random number
  48.    already generated in step 2.
  49.  
  50.        a. The first four digits are read into ThisNumStr for
  51.           later checking in the USEDNUMS file.
  52.  
  53.        b. any remaining text on the same line (up to 40
  54.           characters) will be read into the variable: MemberName
  55.           for display and recording later.
  56.  
  57.    If the file: GOODNUMS.LST doesn't exist the random number will
  58.    be considered valid at this point.
  59.  
  60. 4. RAND2 then opens the file:USEDNUMS.lst to see if the number
  61.    was already used. If it has, you guessed it back to step 2.
  62.    Until the file of used numbers is erased, previous winners
  63.    cannot win again.
  64.  
  65. 5. At this point, RAND has generated a number which IS both a
  66.    member of the first list and NOT a member of the second.  It
  67.    now calls the TITLE.exe to display the number and whether or
  68.    not it won!  Remember that little parameter that you started
  69.    the program with? Lets say that you started with 3.
  70.  
  71.    RAND2 would display the first two numbers as non-winners and
  72.    the third would be marked the winner. ONLY the number marked
  73.    as a winner goes into USEDNUMS.LST. Since we actually started
  74.    the random number generator with a random number. NO WAY to
  75.    fix the output. If the GOODNUMS.LST file is used, it's full
  76.    path is displayed at the time the numbers are displayed and
  77.    the name is hard coded into the program. If used GoodNums.Lst
  78.    MUST exist in the same path that RAND.EXE is in.
  79.  
  80. ┌───────────────────┐
  81. │GOODNUMS.LST FORMAT│
  82. └───────────────────┘
  83. As mentioned above, GOODNUMS.LST is a simple ascii text file. The
  84. first line MUST read: ALL VALID NUMBERS (all caps, no leading or
  85. trailing spaces) after that, each valid number can be entered in
  86. any order on a line by itself. Use a standard text editor (such
  87. as Edlin) to create the file. Although only the first four
  88. characters are used for comparison,the rest of the line can
  89. contain any text that you wish. (member first and last name
  90. suggested)
  91.  
  92. ┌───────────┐
  93. │PERFORMANCE│
  94. └───────────┘
  95. Yes, I know that I could have read all the numbers into an array
  96. and sorted the list first but this is one of the few times when
  97. the object is to create suspense. Let the computer churn a while.
  98. I didn't want the program to get the answer too quickly.. Some
  99. things are best done SLOWLY.. If you really want slow, run from a
  100. floppy disk.
  101.  
  102. ┌────────┐
  103. │FAIRNESS│
  104. └────────┘
  105. For those of you astute enough to spot it, RAND2 does have a
  106. major flaw. If some unscrupulous individual entered his number
  107. more than once (ok a lot more than once) he would have an unfair
  108. advantage over the others. Although the list doesn't need to be
  109. sorted, sorting it just before the drawing and checking for
  110. duplicates could minimize that possibility.
  111.  
  112. If you want to eliminate that possibility use my RAND program
  113. (Ver 5.5) and sleep well, knowing that no one can accuse you of
  114. cheating... It is a little bit slower than RAND2 but uses a
  115. different technique of validating which negates number frequency
  116. problems. While RAND2 seems almost instantaneous (it only scans
  117. the GoodNums file once for each winner.) RAND has been known to
  118. take up to SEVEN to THIRTY SECONDS to find a random number it is
  119. happy with.
  120.  
  121. If you need a quick reference (file names and such) just type
  122.         Rand2 ?
  123. In addition, see Vendor.doc for the use of each file.
  124.  
  125.